<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\AdminApply;
use App\Admin\Override\Form;
use App\Admin\Override\Grid;
use App\Admin\Repositories\AdminConfig;
use App\Utils\Helper;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Repositories\EloquentRepository;

class AdminSourceController extends BaseController
{
    public $translation = 'admin-type';
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new AdminConfig(), function (Grid $grid) {
            $grid->model()->where('type',3)->orderBy('sort','desc');
            $grid->column('name');
            $grid->column('sort');
            $grid->column('created_at');
            $grid->column('updated_at');
            $grid->disableViewButton();
            $grid->quickSearch(['name'])->placeholder('请输入名称');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form(): Form
    {
        return Form::make(new AdminConfig(), function (Form $form) {
           $form->text('name')->required();
           $form->number('sort')->value(1);
           $form->hidden('type')->value(3);
        });
    }

}
